#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "wifiiot_gpio.h"
#include "wifiiot_gpio_ex.h"
#include "oled_ssd1306.h"


void init(void){
    GpioInit();
    OledInit();
}


static void oled_task_run(void *arg){
    (void)arg;
    init();
    OledFillScreen(0x00);

    OledShowString(0,0,"Hell,OS",FONT6x8);
    sleep(1);
    for (int i = 0; i < 3; i++)
    {
        OledFillScreen(0x00);
        for (int y = 0; y < 8; y++)
        {
            static const char text[] = "ABCDEFGHIJKLMNOP";
            OledShowString(0,y,text,FONT6x8);
        }
        sleep(1);
        
    }
    
}

static void oled_task(void){
    osThreadAttr_t attr;
    attr.name = "OledTask";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;

    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 4096;
    attr.priority = osPriorityNormal;


    if (osThreadNew((osThreadFunc_t) oled_task_run,NULL,&attr)==NULL)
    {
        printf("oled_task create failed.\n");
    }
}

SYS_RUN(oled_task);